<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
    <title>课程管理</title>
    <link rel="stylesheet" type="text/css" href="Assets/css/reset.css"/>
    <script type="text/javascript" src="Assets/js/jquery-1.8.3.min.js"></script>
    <link rel="stylesheet" type="text/css" href="Assets/plugins/FlexSlider/flexslider.css">
    <script type="text/javascript" src="Assets/plugins/FlexSlider/jquery.flexslider.js"></script>
    <script type="text/javascript" src="Assets/js/main.js"></script>
    <link rel="stylesheet" type="text/css" href="Assets/css/thems.css">
    <link rel="stylesheet" type="text/css" href="Assets/css/responsive.css">
    <script language="javascript">
    </script>
</head>

<body>
<!--头部-->
<div class="head clearfix">
    <div class="logo"><a href=""><img src="Assets/images/logo.jpg" alt="信本财富"/></a></div>
    <div class="head_r">
        <div class="lang">
            <a href="">中文</a>|
            <a href="">English</a>
        </div>
        <ul class="nav clearfix">
            <li class="now"><a href="index.html">首页</a></li>
            <li><a href="product.html">课程管理</a></li>
            <li><a href="vip.html">会员管理</a></li>
            <li><a href="sig_in.html">签到管理</a></li>
            <li><a href="custom-made.html">定制会员卡</a></li>
            <li><a href="subbranch.html">场馆管理</a></li>
            <li><a href="staff.html">员工管理</a></li>
        </ul>
        <div class="nav_m">
            <span class="n_icon">&nbsp;</span>
            <ul>
                <li><a href="index.html">首页</a></li>
                <li><a href="about.html">关于信本</a></li>
                <li><a href="news.html">信本动态</a></li>
                <li class="now"><a href="product.html">信本业务</a></li>
                <li><a href="#">信本学院</a></li>
                <li><a href="#">社会责任</a></li>
                <li><a href="#">联系我们</a></li>
            </ul>
        </div>
    </div>
</div>
<!--头部-->
<!--幻灯片-->
<div class="banner">
    <div class="slider">
        <div class="flexslider">
            <ul class="slides">
                <li>
                    <a href=""><img src="Assets/upload/banner.jpg" alt="" /></a>
                </li>
                <li>
                    <a href=""><img src="Assets/upload/banner_a.jpg" alt="" /></a>
                </li>
                <li>
                    <a href=""><img src="Assets/upload/banner_b.jpg" alt="" /></a>
                </li>
                <li>
                    <a href=""><img src="Assets/upload/banner_c.jpg" alt="" /></a>
                </li>
                <li>
                    <a href=""><img src="Assets/upload/banner_d.jpg" alt="" /></a>
                </li>
            </ul>
        </div>
    </div>
</div>
<!--幻灯片-->
<div class="scd clearfix">
    <div class="scd_l">
        <div class="title"><span>课程</span></div>
        <ul class="s_nav">
            <li><a href="product.html"><em>返回</em></a></li>
        </ul>
        场馆选择
        <select name="" id="coursestbodyul" onchange="PKQuery()">
            <option selected="selected"  value="">--请选择-- </option>
        </select>

    </div>
    <div class="scd_r">
        <div class="s_title">
            排课管理
            <div class="pst">
                当前位置：
                <a href="">首页</a>>
                <a href="">课程管理</a>>
                <a href="">排课</a>
            </div>
        </div>
        <div class="scd_m">
            <div class="pro">

                <table width="100%" align="center" id="test">
                    <caption><h2>排课表</h2></caption>
                    <tr height="40px"><!-- 标题栏-->
                        <td width="300px" bgcolor="HotPink">上课时间</td>
                        <td width="300px" bgcolor="HotPink" id="date1"></td>
                        <td width="300px" bgcolor="HotPink" id="date2"></td>
                        <td width="300px" bgcolor="HotPink" id="date3"></td>
                        <td width="300px" bgcolor="HotPink" id="date4"></td>
                        <td width="300px" bgcolor="HotPink" id="date5"></td>
                        <td width="300px" bgcolor="HotPink" id="date6"></td>
                        <td width="300px" bgcolor="HotPink" id="date7"></td>
                    </tr>
                    <tr height="40x" align="center">
                        <td rowspan="">8:00-9:30</td>
                        <td rowspan="" bgcolor="Cyan"></td>
                        <td rowspan=""></td>
                        <td rowspan="" bgcolor="orange"></td>
                        <td rowspan=""></td>
                        <td rowspan="" bgcolor="hotpink"></td>
                        <td rowspan=""></td>
                        <td rowspan=""></td>
                    </tr>
                    <tr height="40px" align="center">
                        <td rowspan="">10:00-11:30</td>
                        <td rowspan=""></td>
                        <td rowspan="" bgcolor="springgreen"></td>
                        <td rowspan="" bgcolor="Aquamarine"></td>
                        <td rowspan="" bgcolor="Peru"></td>
                        <td rowspan="" bgcolor="DeepSkyBlue"></td>
                        <td rowspan=""></td>
                        <td rowspan="" bgcolor="Cyan"></td>
                    </tr>


                    <tr height="40px" align="center">

                        <td rowspan="">14:00-15:30</td>
                        <td rowspan="" bgcolor="SpringGreen"></td>
                        <td rowspan="" bgcolor="HotPink"></td>
                        <td rowspan="" bgcolor="Thistle"></td>
                        <td rowspan=""></td>
                        <td rowspan=""></td>
                        <td rowspan="" bgcolor="SpringGreen"></td>
                        <td rowspan="" ></td>

                    </tr>

                    <tr height="40px" align="center">

                        <td rowspan="">16:00-17:30</td>
                        <td rowspan=""></td>
                        <td rowspan="" bgcolor="GreenYellow"></td>
                        <td rowspan="" bgcolor="DeepSkyBlue"></td>
                        <td rowspan="" bgcolor="RoyalBlue"></td>
                        <td rowspan="" bgcolor="DeepSkyBlue"></td>
                        <td rowspan=""></td>
                        <td rowspan="" bgcolor="GreenYellow"></td>

                    </tr>


                    <tr height="40px" align="center">

                        <td rowspan="">19:30-21:00</td>
                        <td rowspan="" bgcolor="MediumOrchid"></td>
                        <td rowspan=""></td>
                        <td rowspan=""></td>
                        <td rowspan="" bgcolor="DeepSkyBlue"></td>
                        <td rowspan=""></td>
                        <td rowspan=""></td>
                        <td rowspan="" bgcolor="MediumOrchid"></td>

                    </tr>



                </table>


            </div>
        </div>
    </div>
</div>

</body>
</html>
<script>
    $(function () {
        var path = "/" + location.pathname.split("/")[1];
        $.get(path+"/shopQuery",function (list) {
            console.log(list+"=================")

            $.each(list,function (i,li) {

                console.log(li)

                $("#coursestbodyul").append(
                    '<option value='+li.shopid+ '>'+li.shopname+'</option>'
                );

            });

        },"json");



        var  time=(new Date()).valueOf();
        var time1 = (60*60*24*1000);
        for (var i=1;i<8;i++){
            function getNow(s) {
                return s < 10 ? '0' + s: s;
            }

            var i2=i-1;
            var time2 =  time+(time1*(i2))
            var t =  new Date(time2);
            var datt= t.getMonth();
            var dat =  getNow(t.getDate());
            var year  = t.getFullYear();
            var dattt= getNow(datt+1);
            console.log(dat+"======="+datt+1);
            $("tr:eq(0) td").eq(i).html(year+"-"+dattt+"-"+dat+"");

        }

    });

    var table=document.getElementById("test")
    tds = table.getElementsByTagName("td");
    for(var i=0,j=tds.length;i<j;i++){
        tds[i].onclick=function(){
            var row = $(this).parent().index(); // 行位置

            var col = $(this).index(); // 列位置

            alert("当前位置：第"+row+"行，第"+col+"列")

            //获取第二行第三列
            // $("tr:eq("+row+") td").eq(col).html("其它名称====");
            console.log($(this).html());
            var  htmlsss= $(this).html();
            if ( htmlsss==""){
                pkAdd($(this));
                console.log("=======没有值")
            }else {
                pkUpdate($(this));
                console.log("=======有值")
            }
        }
    }

    //传送当前表格的日期和时间
    function pkAdd(tdThis) {
        var time = tdThis.parent().index();
        var date1 = tdThis.index();
        var timespk = $("tr:eq(0) td").eq(date1).html();
        var  datespk =$("tr:eq("+time+") td").eq(0).html();

        var toUrl = "add - paike.html?times="+datespk+'&dates='+timespk;
        window.open(toUrl);

    }
    function pkUpdate(tdThis) {
        var time = tdThis.parent().index();
        var date1 = tdThis.index();
        var timespk = $("tr:eq(0) td").eq(date1).html();
        var  datespk =$("tr:eq("+time+") td").eq(0).html();
        var  courseName= tdThis.html();
        var toUrl =encodeURI("delete - paike.html?times="+datespk+'&dates='+timespk+'&courseName='+courseName) ;
        window.open(toUrl);
        // var toUrl = "custom-made-update.html?id="+id;
        // window.open(toUrl);

    }

    function PKQuery() {
        var path = "/" + location.pathname.split("/")[1];
        var ids = $("#coursestbodyul").val();
        console.log(ids+"=================")
        $.get(path+"/coursePKQuery",{"courseClubid":ids},function (list) {
            console.log(list+"=================")
            for (var tr=1;tr<7;tr++) {
                for (var tb=1;tb<8;tb++) {


                    $("tr:eq("+tr+") td").eq(tb).html("");
                }
            }
            $.each(list,function (i,li) {
                var dateiii;
                for (var i=0;i<7;i++){
                    var datesx = $("tr:eq("+i+") td").eq(0).html();
                    var datePX = li.courseDate
                    console.log(datesx+"==对比日期=="+datePX)
                    console.log(datesx==datePX);
                    if (li.courseDate==datesx){
                        dateiii = i;
                    }
                }
                var timeiii;
                for (var i=0;i<8;i++){
                    var timesx = $("tr:eq(0) td").eq(i).html();
                    if (li.courseTime==timesx){
                        timeiii = i;
                    }
                }


                console.log("第几列"+dateiii+"第几行"+timeiii);
                $("tr:eq("+dateiii+") td").eq(timeiii).html(li.courseName+"<br>"+li.courseTeacher);

            });

        },"json");
    }

</script>

